#ifndef GAMEWINDOW4_H
#define GAMEWINDOW4_H

#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QDialog>
#include <QTimer>
#include<QVBoxLayout>
#include<QLabel>
#include<QRandomGenerator>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QPixmap>
#include <QWidget>
#include<QPushButton>
#include<QMediaPlayer>
#include<QMovie>

struct LightOption{
    QString imagePath;
    QString message;
    QString actionType;
};
QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE


class GameWindow4 : public QGraphicsView
{
    Q_OBJECT

public:
    explicit GameWindow4(QWidget *parent = nullptr);
    bool viewportEvent(QEvent *event)override;
    void initScene();
    void moveDogLeft();
    void moveDogRight();
    void loadNextLight();
    void checkProximity();
    void closeEvent(QCloseEvent *event) override;
    void initLightData();
    void onLightClicked(int index);
    void showMessageDialog(const QString &message, const QString &actionType);
    void playSound(const QString &filePath);

protected:
    void keyPressEvent(QKeyEvent *event) override;

signals:
    void dialogResult(bool accepted);

private:
    QGraphicsScene *scene;
    QGraphicsPixmapItem *background;
    QGraphicsPixmapItem *dog;
    QGraphicsPixmapItem *currentLight;
    QGraphicsPixmapItem *leftArrow;
    QGraphicsPixmapItem *rightArrow;
    QPixmap dogLeftPixmap;
    QPixmap dogRightPixmap;
    int currentIndex;
    int moveStep = 10;

private:
    QVector<LightOption> allLightOptions;
    QVector<LightOption> selectedLights;
    Ui::Widget *ui;
    QMediaPlayer *player;
    QAudioOutput *audioOutPut;

signals:
    void gameWindow4Closed();
};

#include <QDialog>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>

class CustomMessageDialog : public QDialog
{
    Q_OBJECT
public:
    explicit CustomMessageDialog(const QString &message, QWidget *parent = nullptr);
    QPushButton *btnAccept;
    QPushButton *btnReject;
signals:
    void dialogResult(bool accepted);

};
#endif // GAMEWINDOW4_H
